using micromsg;
using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Protocol;
using Microsoft.Phone.Info;
using System;
using System.Collections.Generic;
namespace MicroMsg.Scene
{
	public class NetSceneClientPerfReport : NetSceneBaseEx<ClientPerfReportReq, ClientPerfReportResp, ClientPerfReportReq.Builder>
	{
		private const string TAG = "NetSceneClientPerfReport";
		public void doScene(Dictionary<uint, PerfItemInfo> lstItems)
		{
			Log.smethod_4("NetSceneClientPerfReport", "report client perf items , size = " + lstItems.get_Count());
			base.beginBuilder();
			this.mBuilder.BaseRequest = NetSceneBase.makeBaseRequest(0);
			this.mBuilder.DeviceModel = DeviceStatus.get_DeviceName();
			this.mBuilder.DeviceBrand = DeviceStatus.get_DeviceManufacturer();
			this.mBuilder.OsName = string.Concat(Environment.get_OSVersion().get_Platform());
			this.mBuilder.OsVersion = string.Concat(Environment.get_OSVersion().get_Version());
			this.mBuilder.LanguageVer = AccountMgr.GetCurrentLanguage();
			using (Dictionary<uint, PerfItemInfo>.Enumerator enumerator = lstItems.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					KeyValuePair<uint, PerfItemInfo> current = enumerator.get_Current();
					ClientPerfItem.Builder builder = ClientPerfItem.CreateBuilder();
					PerfItemInfo value = current.get_Value();
					builder.EventID = current.get_Key();
					builder.AvgElapseTime = value.avgElapseTime;
					builder.MaxElapseTime = value.maxElapseTime;
					builder.MinElapseTime = value.minElapseTime;
					builder.Cnt = value.count;
					builder.StartTime = value.startTime;
					builder.EndTime = value.endTime;
					this.mBuilder.AddList(builder.Build());
				}
			}
			this.mBuilder.SetEventIdCnt((uint)lstItems.get_Count());
			this.mSessionPack.mConnectMode = 2;
			this.mSessionPack.mCmdUri = "/cgi-bin/micromsg-bin/clientperfreport";
			base.endBuilder();
		}
		protected override void onFailed(ClientPerfReportReq request, ClientPerfReportResp response)
		{
			Log.smethod_1("NetSceneClientPerfReport", "report client perf items onFailed. ");
		}
		protected override void onSuccess(ClientPerfReportReq request, ClientPerfReportResp response)
		{
			RetConst ret = (RetConst)response.BaseResponse.Ret;
			if (ret == RetConst.MM_OK)
			{
				Log.smethod_4("NetSceneClientPerfReport", "report client perf items success.  ");
				return;
			}
			Log.smethod_1("NetSceneClientPerfReport", "report client perf items failed, ret = " + ret);
		}
		public static void test()
		{
		}
	}
}
